<?php
namespace Mouta\AmistateBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Entity\User as BaseUser;
use Symfony\Component\Validator\Constraints as Assert;
use Mouta\AmistateBundle\utils\Strings;
use Symfony\Component\Security\Core\User\UserInterface;

/**
 * Mouta\AmistateBundle\Entity
 * 
 * @ORM\Table(name="mensaje")
 * @ORM\Entity(repositoryClass="Mouta\AmistateBundle\Entity\MensajeRepository")
 */
class Mensaje
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    protected $id;

    /**
     * @ORM\Column(type="text")
     * @Assert\NotBlank()
     */
    protected $body;
    
    /**
     * @ORM\ManyToOne(targetEntity="Asunto"))
     * @ORM\JoinColumn(name="asunto_id", referencedColumnName="id", onDelete="Cascade")
     */
    protected $asunto;
    
    /**
     * @ORM\Column(type="datetime")
     * @Assert\DateTime()
     * @Assert\NotBlank()
     */
    protected $created_at;
    
    /**
     * @ORM\ManyToOne(targetEntity="Usuario")
     * @ORM\JoinColumn(name="de", referencedColumnName="id", onDelete="Cascade")
     */
    protected $de;
    
    /**
     * @ORM\ManyToOne(targetEntity="Usuario")
     * @ORM\JoinColumn(name="para", referencedColumnName="id", onDelete="Cascade")
     */
    protected $para;
    
    /**
     * @ORM\Column(type="boolean")
     * 
     */
    protected $leido = 0;
    
    /**
     * @ORM\ManyToOne(targetEntity="Usuario")
     * @ORM\JoinColumn(name="borrado_por", nullable=true, referencedColumnName="id", onDelete="Cascade")
     */
    protected $borrado_por;
    
    /**
    * @ORM\Column(type="string", nullable=true)
    */
   protected $ip;

    public function __construct(\Symfony\Component\HttpFoundation\Request $request){
        $this->ip = $request->getClientIp();
        $this->created_at = new \DateTime();
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set body
     *
     * @param text $body
     */
    public function setBody($body)
    {
        $this->body = $body;
    }

    /**
     * Get body
     *
     * @return text 
     */
    public function getBody()
    {
        return $this->body;
    }

    /**
     * Set created_at
     *
     * @param datetime $createdAt
     */
    public function setCreatedAt($createdAt)
    {
        $this->created_at = $createdAt;
    }

    /**
     * Get created_at
     *
     * @return datetime 
     */
    public function getCreatedAt()
    {
        return $this->created_at;
    }

    /**
     * Set leido
     *
     * @param boolean $leido
     */
    public function setLeido($leido)
    {
        $this->leido = $leido;
    }

    /**
     * Get leido
     *
     * @return boolean 
     */
    public function getLeido()
    {
        return $this->leido;
    }

    /**
     * Set asunto
     *
     * @param Mouta\AmistateBundle\Entity\Asunto $asunto
     */
    public function setAsunto(\Mouta\AmistateBundle\Entity\Asunto $asunto)
    {
        $this->asunto = $asunto;
    }

    /**
     * Get asunto
     *
     * @return Mouta\AmistateBundle\Entity\Asunto 
     */
    public function getAsunto()
    {
        return $this->asunto;
    }

    /**
     * Set de
     *
     * @param Mouta\AmistateBundle\Entity\Usuario $de
     */
    public function setDe(\Mouta\AmistateBundle\Entity\Usuario $de)
    {
        $this->de = $de;
    }

    /**
     * Get de
     *
     * @return Mouta\AmistateBundle\Entity\Usuario 
     */
    public function getDe()
    {
        return $this->de;
    }

    /**
     * Set para
     *
     * @param Mouta\AmistateBundle\Entity\Usuario $para
     */
    public function setPara(\Mouta\AmistateBundle\Entity\Usuario $para)
    {
        $this->para = $para;
    }

    /**
     * Get para
     *
     * @return Mouta\AmistateBundle\Entity\Usuario 
     */
    public function getPara()
    {
        return $this->para;
    }

    /**
     * Set borrado_por
     *
     * @param Mouta\AmistateBundle\Entity\Usuario $borradoPor
     */
    public function setBorradoPor(\Mouta\AmistateBundle\Entity\Usuario $borradoPor)
    {
        $this->borrado_por = $borradoPor;
    }

    /**
     * Get borrado_por
     *
     * @return Mouta\AmistateBundle\Entity\Usuario 
     */
    public function getBorradoPor()
    {
        return $this->borrado_por;
    }

    /**
     * Set ip
     *
     * @param string $ip
     */
    public function setIp($ip)
    {
        $this->ip = $ip;
    }

    /**
     * Get ip
     *
     * @return string 
     */
    public function getIp()
    {
        return $this->ip;
    }
}